import axios from "../utils/axios";

// 1、表格数据查询(全部以及按条件)
const examorgan = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan/list",
    method: "post",
    data: _data,
  });
  return data;
};

// 2、添加机构，分支机构
const addorgan = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan/add",
    method: "post",
    data: _data,
  });
  return data;
};

// 3、删除机构
const delorgan = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan/delete",
    method: "get",
    params: _data,
  });
  return data;
};

// 4、批量删除机构
const delbatches = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan/deleteBySubIds",
    method: "post",
    data: _data,
  });
  return data;
};

// 5、修改机构
const updateorgan = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan/update",
    method: "post",
    data: _data,
  });
  return data;
};

// 6、根据id查询机构
const search_id = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan",
    method: "get",
    params: _data,
  });
  return data;
};

// 7、列表查询所有
const search_all = async (_data: {}) => {
  const data = await axios({
    url: "/examinationOrgan/findAll",
    method: "get",
    params: _data,
  });
  return data;
};

// 8、省数据查询
const province_all = async (_data: {}) => {
  const data = await axios({
    url: "/province/findAll",
    method: "get",
    params: _data,
  });
  return data;
};

// 9、市数据查询，用provinceId作为参数
const city_search = async (_data: { id: number }) => {
  const data = await axios({
    url: `/city/${_data.id}`,
    method: "get",
  });
  return data;
};

//10、离线号源查询
const stock_list = async (_data: {}) => {
  const data = await axios({
    url: "/stock/list",
    method: "post",
    data: _data,
  });
  return data;
};

//11、单个修改离线号源
const update_stock = async (_data: {}) => {
  const data = await axios({
    url: "/stock/updateTotalNum",
    method: "post",
    data: _data,
  });
  return data;
};

//12、批量修改离线号源(制定号源规则)
const update_Batches = async (_data: {}) => {
  const data = await axios({
    url: "/stock/updateTotalNumBatches",
    method: "post",
    data: _data,
  });
  return data;
};

// 13、列表查询所有机构类型
const type_all = async (_data: {}) => {
  const data = await axios({
    url: "/organType/findAll",
    method: "get",
    params: _data,
  });
  return data;
};

export {
  examorgan,
  addorgan,
  delorgan,
  delbatches,
  updateorgan,
  search_id,
  search_all,
  province_all,
  city_search,
  stock_list,
  update_stock,
  update_Batches,
  type_all,
};
